//
//  SHowListTableViewCell.m
//  QXShowing
//
//  Created by 王道道 on 2018/4/12.
//  Copyright © 2018年 doll_dream. All rights reserved.
//

#import "SHowListTableViewCell.h"
#import "Masonry.h"

@implementation SHowListTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initView];
    }
    return self;
}

/*
 
 - (void)initView {
 //头像
 self.headImage = [[UIImageView alloc]init];
 self.headImage.image = [UIImage imageNamed:@"home-5"];
 self.headImage.layer.masksToBounds = YES;
 self.headImage.layer.cornerRadius = 5;
 [self.contentView addSubview:self.headImage];
 [self.headImage mas_makeConstraints:^(MASConstraintMaker *make) {
 make.centerY.equalTo(self.contentView);
 make.left.equalTo(self.contentView).offset(5);
 //        make.height.width.offset(85);
 make.width.equalTo(self.contentView.mas_width).multipliedBy(340.0/750.0);
 make.width.equalTo(self.headImage.mas_height).multipliedBy(340.0/240.0);
 make.top.equalTo(self.contentView).offset(15);
 }];
 
 //标题
 self.nameLabel = [[UILabel alloc]init];
 self.nameLabel.textColor = Text_Color_000000;
 self.nameLabel.text = @"杭州西博春季博览会";
 self.nameLabel.font = BHFont_Size_15;
 self.nameLabel.numberOfLines = 2;
 [self.contentView addSubview:self.nameLabel];
 [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
 make.top.equalTo(self.headImage);
 make.left.equalTo(self.headImage.mas_right).offset(10);//30
 make.right.equalTo(self.contentView).offset(-15);
 }];
 
 //简介
 self.messageLabel = [[UILabel alloc]init];
 self.messageLabel.textColor = Text_Color_686868;
 self.messageLabel.text = @"简介：公司特与世纪联华超市股份有限公司汽车本着“客户至上，质量为本”的原";
 self.messageLabel.font = BHFont_Size_13;
 self.messageLabel.numberOfLines = 2;
 [self.contentView addSubview:self.messageLabel];
 [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
 make.top.equalTo(self.nameLabel.mas_bottom).offset(7);
 make.left.equalTo(self.nameLabel);
 make.right.equalTo(self.nameLabel);
 }];
 //时间
 self.timeLabel = [[UILabel alloc]init];
 self.timeLabel.textColor = Text_Color_686868;
 self.timeLabel.text = @"时间：04.03-04.16";
 self.timeLabel.font = BHFont_Size_13;
 [self.contentView addSubview:self.timeLabel];
 [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
 make.top.equalTo(self.messageLabel.mas_bottom).offset(10);
 make.left.equalTo(self.nameLabel);
 make.right.equalTo(self.nameLabel);
 make.bottom.equalTo(self.headImage);
 }];
 }
 
 - (void)setModel:(HomeShowListModel *)model {
 if (![BHSettingUtil dataAndStringIsNull:model]) {
 _model = model;
 if (![BHSettingUtil dataAndStringIsNull:model.pic]) {
 [self.headImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@", BH_PicPreString, model.pic]] placeholderImage:[UIImage imageNamed:@"home-1"]];
 }
 self.nameLabel.text = [BHSettingUtil dataAndStringIsNull:model.title]?@"":model.title;
 self.messageLabel.text = [BHSettingUtil dataAndStringIsNull:model.Description]?@"":model.Description;
 
 NSString *timeStr = [NSString stringWithFormat:@"%@~%@", [BHSettingUtil dataAndStringIsNull:model.start_date]?@"":model.start_date, [BHSettingUtil dataAndStringIsNull:model.end_date]?@"":model.end_date];
 self.timeLabel.text = timeStr;
 }
 }
 */

- (void)initView {
    //标题
    self.nameLabel = [[UILabel alloc]init];
    self.nameLabel.textColor = Text_Color_000000;
    self.nameLabel.text = @"杭州西博春季博览会";
    self.nameLabel.font = BHFont_Size_15;
    self.nameLabel.numberOfLines = 2;
    [self.contentView addSubview:self.nameLabel];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(15);
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(self.contentView).offset(-15);
    }];

    //时间
    self.timeLabel = [[UILabel alloc]init];
    self.timeLabel.textColor = Text_Color_686868;
    self.timeLabel.text = @"时间：04.03-04.16";
    self.timeLabel.font = BHFont_Size_13;
    [self.contentView addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLabel.mas_bottom).offset(10);
        make.left.equalTo(self.nameLabel);
        make.right.equalTo(self.nameLabel);
        make.bottom.equalTo(self.contentView).offset(-15);
    }];
}

- (void)setModel:(HomeShowListModel *)model {
    if (![BHSettingUtil dataAndStringIsNull:model]) {
        _model = model;
//        if (![BHSettingUtil dataAndStringIsNull:model.pic]) {
//            [self.headImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@", BH_PicPreString, model.pic]] placeholderImage:[UIImage imageNamed:@"home-1"]];
//        }
        self.nameLabel.text = [BHSettingUtil dataAndStringIsNull:model.title]?@"":model.title;
//        self.messageLabel.text = [BHSettingUtil dataAndStringIsNull:model.Description]?@"":model.Description;
        
        NSString *timeStr = [NSString stringWithFormat:@"%@/%@", [BHSettingUtil dataAndStringIsNull:model.start_date]?@"":model.start_date, [BHSettingUtil dataAndStringIsNull:model.end_date]?@"":model.end_date];
        self.timeLabel.text = timeStr;
    }
}

@end
